package com.welsy.user.command
{
	import com.adobe.cairngorm.commands.Command;
	import mx.rpc.IResponder;
	import com.adobe.cairngorm.control.CairngormEvent;
	import mx.controls.Alert;
	import com.welsy.usermgt.business.GetSrcCriteriaDelegate;
	import com.welsy.usermgt.model.UserMgtModelLocator;
	import mx.collections.ArrayCollection;
	import com.adobe.cairngorm.model.ModelLocator;
	import com.welsy.util.NamespaceLocator;
	import com.welsy.user.business.GetUserItersDelegate;
	import com.welsy.user.event.GetUserItersEvent;
	import com.welsy.iter.vo.IterVO;
	import com.welsy.user.view.iterview.IterView;
	import com.welsy.user.view.iterview.IterView;
	import com.welsy.user.model.UserModelLocator;
	import com.welsy.user.view.iterview.IterView;
	import com.welsy.user.business.GetIterElementsFromIterDelegate;
	import com.welsy.user.event.GetIterElementsFromIterEvent;
	
	public class GetIterElementsFromIterCommand implements Command, IResponder
	{
		
		
		private var umodel : UserModelLocator = UserModelLocator.getInstance();
		
		public function execute(event : CairngormEvent) : void {
			var delegate : GetIterElementsFromIterDelegate = new GetIterElementsFromIterDelegate(this);
			var eve : GetIterElementsFromIterEvent = GetIterElementsFromIterEvent(event);
			delegate.getIterElements(eve.userId, eve.iterId, eve.roleId, eve.status);
		}
		
		public function result( event : Object ) : void {
			
			var xres : XMLList = XMLList(event.result);
			
			var NS : Namespace = new Namespace(NamespaceLocator.TRACK_DATATYPES);
						
			var TAG_ITERELEMENTSSCOLLECTION : QName = new QName(NS, "IterElementsCollection");
			umodel.elements = GetUserPendingCoursesCommand.parseUserCourses(xres.descendants(TAG_ITERELEMENTSSCOLLECTION).children());
		}
		
		public function fault(event : Object) : void {
			Alert.show("GetIterElementsFromIterCommand.fault");
		}
		
	}
}